package com.bing.autoconfig;

import com.bing.animal.Cat;
import com.bing.animal.Dog;
import com.bing.anotation.Bing;
import com.bing.scanner.BingScanner;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

public class BingAutoConfigBeanDefinitonRegistrar implements ImportBeanDefinitionRegistrar {




    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry, BeanNameGenerator importBeanNameGenerator) {
        ImportBeanDefinitionRegistrar.super.registerBeanDefinitions(importingClassMetadata, registry, importBeanNameGenerator);
    }

    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
        ImportBeanDefinitionRegistrar.super.registerBeanDefinitions(importingClassMetadata, registry);
        GenericBeanDefinition definition = new GenericBeanDefinition();
        definition.setBeanClass(BingScanner.class);
        definition.getPropertyValues().addPropertyValue("annotationClass",Bing.class);
        definition.getPropertyValues().addPropertyValue("basePackage","com.bing.business");
        registry.registerBeanDefinition(BingScanner.class.getName(),definition);
    }
}
